package org.example.springboot.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import org.example.springboot.common.service.impl.BaseServiceImpl;
import org.example.springboot.convert.ETConvert;
import org.example.springboot.dao.ETDao;
import org.example.springboot.entity.DecisionTime;
import org.example.springboot.entity.ET;
import org.example.springboot.service.DecisionTimeService;
import org.example.springboot.service.ETService;
import org.example.springboot.vo.ETVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Fz
 * @since 1.0.0 2024-07-31
 */
@Service
@AllArgsConstructor
public class ETServiceImpl extends BaseServiceImpl<ETDao, ET> implements ETService {

    @Resource
    private DecisionTimeService decisionTimeService;

    @Override
    public boolean doSaveOrUpdate(JSONObject irrigationTypeMsg, String uuid) {
        ETVO etvo = JSON.parseObject(JSON.toJSONString(irrigationTypeMsg), ETVO.class);
        ET et = ETConvert.INSTANCE.convert(etvo);
        et.setIrrigationUnitUuid(uuid);
        return this.saveOrUp(et);
    }

}